#ifndef MACROS_H
#define MACROS_H

#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
#define format_printf(format_idx, arg_idx)                      \
  __attribute__((__format__(__printf__, format_idx, arg_idx)))
#define unused __attribute__((unused))
#else
#define format_printf(format_idx, arg_idx)
#define unused
#endif

#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
#define _BOOLEAN_EXPR_(expr)                    \
  __extension__ ({                              \
      int _boolean_var_;                        \
      if (expr)                                 \
        _boolean_var_ = 1;                      \
      else                                      \
        _boolean_var_ = 0;                      \
      _boolean_var_;                            \
    })
#define likely(expr) (__builtin_expect(_BOOLEAN_EXPR_(expr), 1))
#define unlikely(expr) (__builtin_expect(_BOOLEAN_EXPR_(expr), 0))
#else
#define likely(expr) (expr)
#define unlikely(expr) (expr)
#endif

#endif
